package com.skyline.wo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.skyline.base.controller.BaseController;
import com.skyline.common.util.ViewPaths;
import com.skyline.user.model.User;
import com.skyline.wo.service.InviteService;

@Controller
@RequestMapping("/invite")
public class InviteController extends BaseController {

	@Autowired
	private InviteService inviteService;

//	@Value("${view.invite.request}")
//	private String inviteRequestView;
//
////	@Value("${view.invite.success}")
//	private String inviteSuccessView;

	@RequestMapping(value = "/joinUs", method = RequestMethod.GET)
	public ModelAndView inviteRequest() {
		ModelAndView mav = new ModelAndView();
		checkAndReturnLoginedUser();
		mav.setViewName(ViewPaths.INVITE_REQUEST);
		return mav;
	}

	@RequestMapping(value = "/joinUs", method = RequestMethod.POST)
	public ModelAndView inviteExecute(String[] emails,int valideEmailCount) {
		ModelAndView mav = new ModelAndView();
		User user = checkAndReturnLoginedUser();
			//System.out.println(valideEmailCount);
		inviteService.sendInvitation(emails, user,valideEmailCount);
		mav.setViewName(ViewPaths.INVITE_SUCCESS);
		return mav;
	}
}
